package thread.src.api;

public class ThreadDemo {
    //main方法是由主线程负责调度的
    public static void main(String[] args) throws Exception {
        Thread t1 = new MyThread();
        t1.setName("子线程1");
        t1.start();

        Thread t2 = new MyThread("子线程2");
        t2.start();

        //主线程,名字默认就是main
        //这个静态方法就是用来获取当前线程的
        Thread now = Thread.currentThread();
        for (int i = 0; i < 5; i++) {
            //sleep是静态方法,作用就是使线程休眠
            if(i==3) Thread.sleep(2000);
            System.out.println("main线程输出: " + i);
        }
    }
}
